<% layout('/layouts/default.html', {title: '涉密文件日志审计管理', libs: ['dataGrid']}){ %>

<div class="main-content">
    <div class="box-body">
        <div>
            <a href="#" class="btn btn-default" onclick="select('year')">当年</a>
            <a href="#" class="btn btn-default " onclick="select('month')">当月</a>


            <#form:input id="start"  readonly="true" maxlength="20" class=" btn btn-default form-control laydate width-date"

            dataFormat="date" data-type="date" data-format="yyyy-MM-dd" data-done="logDate_lte.click()"/>
            &nbsp;-&nbsp;
            <#form:input id="end"  readonly="true" maxlength="20" class="btn btn-default form-control laydate width-date"
            dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
            <a href="#" class="btn btn-default " onclick="find()">确定</a>
        </div>

        <div id="main" style="width: 1200px;height:700px;"></div>

    </div>
</div>
<% } %>
<script src="${ctxStatic}/common/echarts.min.js"></script>
<script>
    function find(){
        var start= $("#start").val()
        var end= $("#end").val()
        if (start==""){
            js.layer.msg("设置开始时间",{icon:5})
        }else if (end==""){
            js.layer.msg("设置结束时间",{icon:5})
        }else{
            show(start.substring(0,10),end.substring(0,10));
        }

    }
    window.onload=function(){
        select("month")

    }
    function select(data) {
        var da=new Date();
        var nowTime= da.toJSON();
        if(data=="month"){
            nowTime= nowTime.substring(0,7)
        }else if(data=="year"){
            nowTime=nowTime.substring(0,4)
        }
        show(nowTime,'')

    }
    function show(begin,end) {
        $.ajax({
            type: "POST",
            url: "${ctx}/sd/docDeliverRecord/sendAnalysis?begin="+begin+"&end="+end,
            success:function (data) {
                var lvl=new Array();
                var dat=new Array();
                var val=new Array();
                var val1=new Array();
                var val2=new Array();
                var val3=new Array();
                var val4=new Array();
                var series=[];
                if (data.length>0){
                    for (var i=0;i<data.length;i++){
                        console.log(data)
                        dat.push(data[i].officeName)
                        val.push(data[i].publicNumber)
                        val1.push(data[i].innerNumber)
                        val2.push(data[i].secretNumber)
                        val3.push(data[i].confidentialNumber)
                        val4.push(data[i].topSecretNumber)


                    }

                    lvl.push("公开")
                    lvl.push("内部")
                    lvl.push("秘密")
                    lvl.push("机密")
                    lvl.push("绝密")


                    series.push({
                        name: "公开",
                        type: 'line',
                        areaStyle: {},
                        stack: '总量',
                        data: val
                    });

                    series.push({
                        name:"内部",
                        type: 'line',
                        areaStyle: {},
                        stack: '总量',
                        data: val1
                    });

                    series.push({
                        name: "秘密",
                        type: 'line',
                        areaStyle: {},
                        stack: '总量',
                        data: val2
                    });
                    series.push({
                        name:"机密",
                        type: 'line',
                        areaStyle: {},
                        stack: '总量',
                        data: val3
                    });

                    series.push({
                        name: "绝密",
                        type: 'line',
                        areaStyle: {},
                        stack: '总量',
                        data: val4
                    });
                    option = {
                        title: {
                            text: '来文情况'
                        },
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'cross',
                                label: {
                                    backgroundColor: '#6a7985'
                                }
                            }
                        },
                        legend: {
                            data: lvl
                        },
                        toolbox: {
                            feature: {
                                saveAsImage: {}
                            }
                        },
                        grid: {
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: 'category',
                                boundaryGap: false,
                                data: dat
                            }
                        ],
                        yAxis: [
                            {
                                type: 'value'
                            }
                        ],
                        series: series,

                    };
                    var myChart = echarts.init(document.getElementById('main'));
                    myChart.setOption(option);
                }




            }
        })
    }

</script>